<%--
  Created by IntelliJ IDEA.
  User: Chen
  Date: 2016/3/11
  Time: 22:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fns" uri="http://java.sun.com/jsp/jstl/functionss" %>


<c:set var="ctx" value="${pageContext.request.contextPath}" />
<h4>资料修改</h4>
<form id="profile-form1" class="form-horizontal well">

    <div class="form-group">
        <label class="col-lg-2 col-md-3 col-sm-2 col-xs-12 control-label"></label>
        <div class="col-lg-4 col-md-6 col-sm-9 col-xs-12">
            <img class="img-rounded" width="100px" height="100px" src="http://localhost:8080/paper/commons/attachment/download/${user.avatar}/100x100" style="margin-right: 5px;">
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-2 col-md-3 col-sm-2 col-xs-12 control-label">教师姓名:</label>
        <div class="col-lg-4 col-md-6 col-sm-9 col-xs-12">
            <span>${user.name}</span>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-2 col-md-3 col-sm-2 col-xs-12 control-label">教师性别:</label>
        <div class="col-lg-4 col-md-6 col-sm-9 col-xs-12">
            <c:forEach items="${fns:getDictList('user_gender')}" var="dict">
                <input type="radio" name="gender" disabled="disabled" value="${dict.value}" ${user.gender == dict.value?"checked":""}> ${dict.label}
            </c:forEach>
        </div>
    </div>
    <div class="form-group">
        <label  class="col-lg-2 col-md-3 col-sm-2 col-xs-12 control-label">出生日期:</label>
        <div class="col-lg-4 col-md-6 col-sm-9 col-xs-12">
            <span><fmt:formatDate value="${user.birthdate}" pattern="yyyy-MM-dd" /></span>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-2 col-md-3 col-sm-2 col-xs-12 control-label">邮箱:</label>
        <div class="col-lg-4 col-md-6 col-sm-9 col-xs-12">
            <span>${user.email}</span>
        </div>
    </div>
    <div class="form-group">
        <label  class="col-lg-2 col-md-3 col-sm-2 col-xs-12 control-label">联系电话:</label>
        <div class="col-lg-4 col-md-6 col-sm-9 col-xs-12">
            <span>${user.phone}</span>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-2 col-md-3 col-sm-2 col-xs-12 control-label">QQ:</label>
        <div class="col-lg-4 col-md-6 col-sm-9 col-xs-12">
            <span>${user.qq}</span>
        </div>
    </div>
    <div class="form-group">
        <label  class="col-lg-2 col-md-3 col-sm-2 col-xs-12 control-label">指导类型:</label>
        <div class="col-lg-4 col-md-6 col-sm-9 col-xs-12">
            <c:forEach items="${fns:getDictList('topic_type')}" var="dict">
                <input type="radio" name="direct" disabled="disabled" value="${dict.value}" ${user.direct == dict.value?"checked":""}> ${dict.label}
            </c:forEach>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-2 col-md-3 col-sm-2 col-xs-12 control-label">研究方向:</label>
        <div class="col-lg-4 col-md-6 col-sm-9 col-xs-12">
            <span>${user.study}</span>
        </div>
    </div>
</form>
<div>
    <button data-toggle="modal" data-target="#myModal" class="btn btn-warning btn-sm college-details" value="${user.id}">修改</button>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">
                    修改资料
                </h4>
            </div>
            <div class="modal-body">
                <form id="profile-form">
                    <div class="form-group">
                        <input type="hidden" id="id" name="id" value="${user.id }">
                        <input type="hidden" id="loginName" name="loginName" value="${user.loginName }">
                        <input type="hidden" id="name" name="name" value="${user.name }">
                        <input type="hidden" id="gender" name="gender" value="${user.gender }">
                        <input type="hidden" id="birthdate" name="birthdate" value="<fmt:formatDate value="${user.birthdate}" pattern="yyyy-MM-dd" />">

                        <div>
                            <div class="media" style="border-bottom: 0;">
                                <a class="pull-left" href="#">
                                    <c:if test="${user.avatar!=null}">
                                        <img id="avatar-preview" class="media-object img-rounded" src="${ctx}/commons/attachment/download/${user.avatar}/100x100" alt="..." style="width: 100px;height: 100px;">
                                    </c:if>
                                    <c:if test="${user.avatar==null}">
                                        <img id="avatar-preview" class="media-object img-rounded"  alt="..." style="width: 100px;height: 100px;">
                                    </c:if>
                                </a>
                                <div class="media-body  visible-sm visible-md visible-lg" style="width: 200px;">
                                    <button type="button" class="btn btn-default btn-sm avatar-edit-button">选择头像</button>
                                    <p class="help-block">支持 JPG、PNG、GIF 格式，不超过 2M 。</p>
                                </div>
                            </div>
                        </div>
                        <label class="control-label">邮箱:</label>
                        <div>
                            <input type="text" class="form-control" id="email" name="email" value="${user.email }">
                        </div>
                        <label class="control-label">联系电话:</label>
                        <div>
                            <input type="text" class="form-control" id="phone" name="phone" value="${user.phone }">
                        </div>
                        <label class="control-label">QQ:</label>
                        <div>
                            <input type="text" class="form-control" id="qq" name="qq" value="${user.qq }">
                        </div>
                        <label class="control-label">指导类型:</label>
                        <div>
                            <c:forEach items="${fns:getDictList('topic_type')}" var="dict">
                                <input type="radio" name="direct" value="${dict.value}" ${user.direct == dict.value?"checked":""}> ${dict.label}
                            </c:forEach>
                        </div>
                        <label class="control-label">研究方向:</label>
                        <div>
                            <input type="text" class="form-control" id="study" name="study" value="${user.study }">
                        </div>
                    </div>
                </form>
                <div class="modal-footer">
                    <button type="button" id="profile-submit" class="btn btn-primary ">保存</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>


<script type="text/javascript">
    <c:if test="${env == 'pro' }">
    requirejs(['${ctx}/assets/js/app/teacher/user-profile-page.js']);
    </c:if>
    <c:if test="${env != 'pro' }">
    requirejs(['${ctx}/assets/js/app/teacher/user-profile-page.js']);
    </c:if>
</script>